﻿namespace OpenAdmin.Core.Consts
{
    /// <summary>
    /// 缓存
    /// </summary>
    public class CachingConsts
    {
        /// <summary>
        /// 前缀
        /// </summary>
        public class CachePrefix
        {
            /// <summary>
            /// 商城
            /// </summary>
            public const string Mall = "Mall";
            /// <summary>
            /// 商品
            /// </summary>
            public const string Mall_Product = Mall + ":Product";
        }
        /// <summary>
        /// key
        /// </summary>
        public class CacheKeys
        {
            /// <summary>
            /// 
            /// </summary>
            /// <param name="parameter"></param>
            /// <param name="pageIndex"></param>
            /// <param name="pageSize"></param>
            /// <returns></returns>
            public static string ProductListByPageAsync(string parameter, int pageIndex, int pageSize) => $"{CachePrefix.Mall_Product}:List-{parameter}-{pageIndex}-{pageSize}";

            //public static string GetPosts(int page, int limit) => $"{CachePrefix.Blog_Post}:Get-{page}-{limit}";

            //public static string GetPostsByCategory(string category) => $"{CachePrefix.Blog_Post}:GetByCategory-{category}";

            //public static string GetPostsByTag(string tag) => $"{CachePrefix.Blog_Post}:GetByTag-{tag}";

            //public static string GetCategories() => $"{CachePrefix.Blog_Category}:Get";

            //public static string GetTags() => $"{CachePrefix.Blog_Tag}:Get";

            //public static string GetFriendLinks() => $"{CachePrefix.Blog_FriendLink}:Get";

            //public static string GetSources() => $"{CachePrefix.Hot}:Sources";

            //public static string GetHots(string source) => $"{CachePrefix.Hot}:{source}";

            //public static string GetSignatureTypes() => $"{CachePrefix.Signature}:Types";

            //public static string GenerateSignature(string name, int typeId) => $"{CachePrefix.Signature}:{name}-{typeId}";
        }
        /// <summary>
        /// 缓存策略
        /// </summary>
        public class CacheStrategy
        {
            /// <summary>
            /// 永不过期
            /// </summary>
            public const int NEVER = -1;

            /// <summary>
            /// 1小时后过期
            /// </summary>
            public const int ONE_HOURS = 60;

            /// <summary>
            /// 12小时后过期
            /// </summary>
            public const int HALF_DAY = 720;
        }
    }
}
